<template>
    <div>
        <h3>账号密码登录</h3>
        <van-form @submit="onSubmit" class="inpp">
            <van-cell-group inset>
                <van-field v-model="userInfo.username" type="username" name="username" label="+86" placeholder="账号"
                    :rules="[{ required: true, message: '请填写账号' }]" />
                <van-field v-model="userInfo.password" type="password" name="password" label="密码" placeholder="密码"
                    show-password :rules="[{ required: true, message: '请填写密码' }]" /><van-icon name="eye" class="an"
                    @click="dj" />
            </van-cell-group>
            <span class="span1">忘记密码？</span>
            <div style="margin: 16px;">
                <van-button round block type="primary" native-type="submit" >
                    登录
                </van-button>
            </div>
        </van-form>
        <van-radio-group v-model="checke" shape="square " @click="qx">
            <van-radio>我同意遵守啥时候是是是</van-radio>
        </van-radio-group>
    </div>
</template>

<script setup>
import { ref } from 'vue';
import { usedl } from '../pinia';
import { setActivePinia } from 'pinia';
import { useRouter } from 'vue-router';
import { flat } from 'vant/lib/utils';
const router = useRouter()
const { userInfo } = setActivePinia(usedl())
const onSubmit = ({ username, password }) => {
    if (username.length == 11) {
        if (userInfo.username == '18366260720' && userInfo.password == '123456') {
            alert('登录成功')
            localStorage.setItem('token', 'adgdhdjdkdldsdldsksj')
            router.push('/home/my')
        }
        else {
            alert('登录失败')
        }
        console.log(userInfo);
    }
    else {
        alert('请输入11位号码')
    }
};
const disabled=ref(false)
const checke=ref(true)
const qx=()=>{
    disabled.value=false
}
</script>

<style>
h3 {
    text-align: center;
    line-height: 50px;
}

.span1 {
    margin-left: 290px;
}

.an {
    position: absolute;
    top: 60px;
    left: 330px;
}

.inpp {
    position: relative;
}
</style>